const mongoose = require('mongoose');
const {mongo} = require('../config');
const Contest = require('./contest');

if (!mongo || !mongo.uri) {
    console.error('MongoDB URI is not defined');
    process.exit(1);
}
mongoose.connect(mongo.uri);
const db = mongoose.connection;
db.on('error', err => {
    console.error('MongoDB connection error:', err);
    process.exit(1);
});
db.once('open', function() {
    console.log('Connected to MongoDB');
})

module.exports = {
    Contest,
}